<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Vue指令(下)</title>
    <script type="text/javascript" src="js/vue.js"></script>
    <style>
        .c1{
            color:blue;
        }
        .success{
            color:green;
        }
        .error{
            color:red;
        }
    </style>
</head>
<body>
<div id="d1">
    <!--<img v-bind:src="url" alt="图片加载失败">-->
    <!--<img v-bind:src="url" alt="图片加载失败" v-bind:width="width">-->
    <img :src="url" alt="图片加载失败" :width="width"><br/>

    <input type="text" :class="{success:flag,error:!flag}" @input="check($event.target.value)"><br/>

    <h2>v-model</h2>
    <!-- v-model双向数据绑定 -->
    <input type="text" v-model="username"><br/>
    <select v-model="edu">
        <option value="-1">请选择</option>
        <option value="1">大专</option>
        <option value="2">本科</option>
        <option value="3">研究生</option>
    </select><br/>
    <textarea cols="30" rows="5" v-model="text"></textarea><br/>
    单选框:<input type="radio" value="man" v-model="gender">男
    <input type="radio" value="woman" v-model="gender">女<br/>
    多选框:
    <input type="checkbox" v-model="hobbies" value="1">吃饭
    <input type="checkbox" v-model="hobbies" value="2">睡觉
    <input type="checkbox" v-model="hobbies" value="3">打豆豆

</div>
<script>
    new Vue({
        el:"#d1",
        data:{
            url:"https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.jj20.com%2Fup%2Fallimg%2F911%2F111G5133543%2F15111G33543-1.jpg&refer=http%3A%2F%2Fpic.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1650697456&t=1b00f8a4c875967e6b6c142111a63c2c",
            width:"300px",
            flag:true,
            username:"孙尚香",
            edu:"1",
            text:"这是一个多行文本框",
            gender:"man",
            hobbies:[1,3]
        },
        methods:{
            check(value){
                this.flag = value.length >= 6 && value.length <= 12;
            }
        }
    });
</script>
</body>
</html>